package com.settlement.system.service.impl;

import com.settlement.system.mapper.BaseMapper;
import com.settlement.system.mapper.TblOrderFinAdjustAccountMapper;
import com.settlement.system.common.exception.ServiceException;
import com.settlement.system.model.entity.common.TblOrderFinAdjustAccount;
import com.settlement.system.service.ITblOrderFinAdjustAccountService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import jakarta.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 订单稽核-财务调账表 服务实现类
 *
 * @author Ximi
 * @since 2020-09-09
 */
@Service
public class TblOrderFinAdjustAccountServiceImpl extends BaseServiceImpl implements ITblOrderFinAdjustAccountService {

    @Resource
    private TblOrderFinAdjustAccountMapper tblOrderFinAdjustAccountMapper;

    @Override
    public BaseMapper init() {
        return tblOrderFinAdjustAccountMapper;
    }

    @Override
    public TblOrderFinAdjustAccount getById(String id) throws ServiceException {
        try {
            return tblOrderFinAdjustAccountMapper.getById(id);
        } catch (Exception ex) {
            throw new ServiceException("通过ID获取财务调整异常", ex);
        }
    }

    @Override
    @Transactional(rollbackFor = ServiceException.class)
    public Integer virtualDelete(List<TblOrderFinAdjustAccount> list) throws ServiceException {
        try {
            for (TblOrderFinAdjustAccount adjustAccount : list) {
                tblOrderFinAdjustAccountMapper.virtualDelete(adjustAccount.getId());
            }
            return list.size();
        } catch (Exception ex) {
            throw new ServiceException("虚拟删除财务调账异常", ex);
        }
    }

    @Override
    public TblOrderFinAdjustAccount selectFoot(Map<String, Object> params) throws ServiceException {
        try {
            return tblOrderFinAdjustAccountMapper.selectFoot(params);
        } catch (Exception e) {
            throw new ServiceException(e);
        }
    }
}

